// -----------------------------------------------------------------------
//  <copyright file="EntityInfoPack.cs" company="OSharp开源团队">
//      Copyright (c) 2014-2020 OSharp. All rights reserved.
//  </copyright>
//  <site>http://www.osharp.org</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2020-02-10 20:14</last-date>
// -----------------------------------------------------------------------


namespace OSharp.Authorization.EntityInfos;

/// <summary>
/// 实体信息模块
/// </summary>
[Description("数据实体模块")]
public class EntityInfoPack : OsharpPack
{
    /// <summary>
    /// 获取 模块级别
    /// </summary>
    public override PackLevel Level => PackLevel.Application;

    /// <summary>
    /// 将模块服务添加到依赖注入服务容器中
    /// </summary>
    /// <param name="services">依赖注入服务容器</param>
    /// <returns></returns>
    public override IServiceCollection AddServices(IServiceCollection services)
    {
        services.TryAddSingleton<IEntityInfoHandler, EntityInfoHandler>();

        return base.AddServices(services);
    }

    /// <summary>
    /// 应用模块服务
    /// </summary>
    /// <param name="provider">服务提供者</param>
    public override void UsePack(IServiceProvider provider)
    {
        IEntityInfoHandler handler = provider.GetService<IEntityInfoHandler>();
        handler.Initialize();
        IsEnabled = true;
    }
}